package com.phospherus.common.repository;

import com.phospherus.common.SerialNumber;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author songjinlong
 * @version 1.0
 * @since 2018/1/5
 */
public interface SerialNumberRepository extends BaseRepository<SerialNumber, Integer> {
    SerialNumber findByYear(String year);

    @Modifying
    @Query(value = "update serial_number set curr_num=:maxNum where id=:id", nativeQuery = true)
    void updateCurrNumById(@Param("id") Integer id, @Param("maxNum") int maxNum);
}
